﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using UIWindow.Domains;
using UIWindow.Entitys;
using UIWindow.Helper;

namespace UIWindow
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            _ = ProductionData.FindCount();
            if (!Directory.Exists(GlobalStart.ConfigPath)) Directory.CreateDirectory(GlobalStart.ConfigPath);
            string device = AppDomain.CurrentDomain.BaseDirectory.Substring(0, 1);
            int count = Process.GetProcessesByName("UIWindow").Length;
            if ((count > 1) || (device.GetHardDiskFreeSpace() < 1))
            {
                MessageBox.Show(count > 1 ? $"不可以重复打开软件！！！" : $"{device}硬盘容量过小，请手动清理垃圾或删除旧数据", "Xing丶Lucifer");
                Current.Shutdown();
            }
            log4net.Config.XmlConfigurator.Configure(new FileInfo(GlobalStart.Log4NetPath));

            //small size ioc
            _ = Bootstrapper.Instance;
        }
    }
}
